<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title></title>


    <style type="text/css">
        .search_input {
            overflow: visible;
            background-color: #FFFFFF;
            background-image: none;
            border: 1px solid #e5e6e7;
            border-radius: 1px;
            color: inherit;
            display: block;
            padding: 6px 12px;
            transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
        }
    </style>
</head>

<body>


<div class="breadcome-area">
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="breadcome-list single-page-breadcome">
                    <div class="row">

                        <form id="searchForm">
                            <div class="col-lg-2 col-md-2 col-sm-2">

                                <input type="text" name="trainNo" placeholder="请输入机车号"
                                       class="search-int form-control">

                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2">
                                <input type="text" name="departmentName" placeholder="请输入部门"
                                       class="search-int form-control">
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2">
                                <input type="text" name="jobName" placeholder="请输入岗位"
                                       class="search-int form-control">
                            </div>

                        </form>
                        <div class="col-lg-2 col-md-2 col-sm-2">
                            <button class="btn btn-primary" onclick="operation.searchForm()">查询</button>
                            <!--
                                                                        <a href="javascript:void(0)" onclick="operation.searchForm()"><i class="fa fa-search"></i></a>
                            -->
                        </div>


                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="mg-b-15">
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="product-status-wrap drp-lst">
                    <h4>检修台账</h4>
                    <!-- <div class="add-product">
                         <a href="#"onclick="operation.addWindow()">添加</a>
                     </div>-->
                    <div class="asset-inner">

                        <table id="dg"></table>


                    </div>


                </div>
            </div>
        </div>
    </div>
</div>


<!-- 第一个model 开始 -->
<div id="setFormModal" class="modal fade" tabindex="-1" role="dialog" data-backdrop="static" data-keybord="false">
    <div class="modal-dialog" style="width:900px">
        <div class="modal-content">
            <div class="modal-header">
                执行详情
            </div>
            <!-- modal-body 开始 -->
            <div class="modal-body">

                <table id="dgmenu"></table>

            </div>
            <!-- modal-body 结束 -->
            <div class="modal-footer">

                <button id="delete_save_btn" type="button" class="btn btn-default btn-outline btn-sm"
                        onclick="operation.closeMoal()">
                    <span class="glyphicon glyphicon-remove"></span>关闭
                </button>
            </div>

        </div>
    </div>
</div>
<!-- 第一个model 结束 -->

<!-- Page-Level Scripts -->
<script type="text/javascript" th:inline="none">

    var operation = {
        searchForm: function () {
            $('#dg').bootstrapTable("refresh");
        },
        //弹出添加页面
        addWindow: function (planDetailId) {
            $('#setFormModal').modal('show');


            var columns = [[
                {
                    field: 'ck',
                    width: '2%',
                    checkbox: false,
                    align: 'center',

                },
                {
                    field: 'id',
                    title: 'id',
                    width: 10,
                    align: 'center',
                    visible: false
                },

                {title: '计划', field: 'planId', align: 'center', valign: 'middle', visible: false},
                {title: '清单类型', field: 'repairTypeName', align: 'center', valign: 'middle', visible: true},

                {title: '清单名称', field: 'menuTitle', align: 'center', valign: 'middle', visible: true},

                {title: '清单ID', field: 'repairMenuId', align: 'center', valign: 'middle', visible: false},

                {title: '是否完成', field: 'isComplete', align: 'center', valign: 'middle', visible: true},
                {title: '备注', field: 'remark', align: 'center', valign: 'middle', visible: true},


            ]];

            $('#dgmenu').bootstrapTable("destroy");
            $('#dgmenu').bootstrapTable({
                url: "/ZcxMenuExcute/findList",
                sidePagination: "server",
                queryParams: function (params) {
                    var temp = {planId: planDetailId};
                    return temp;
                },
                method: "post",
                contentType: "application/x-www-form-urlencoded",
                pagination: false,
                pageNumber: 1,
                pageSize: 10,
                pageList: [10, 25, 50, 100],
                //search:true,
                clickToSelect: true,
                singleSelect: true,
                toolbar: '#toolbar',
                columns: columns,
            })

        },
        //关闭页面
        closeMoal: function () {
            //$('#setFormId').data('bootstrapValidator').resetForm(true);

            $('#setFormModal').modal('hide');
        },

    }


    $(function () {
        //表格格式化
        var fmt = {
            queryParams: function (params) {
                var temp = getFormJson("searchForm");
                temp.rows = params.limit;
                temp.currentPage = (params.offset / params.limit) + 1;
                temp.userId = $("#userId").val();
                return temp;

            },
            setTime: function (value, row, index) {

                return formatTimeYMDhms(value);  //转成年月日时分秒
            },
            setOpt: function (value, row, index) {
                var html = '';
                /* '<button class="btn-white btn btn-xs">查看</button>'+ */
                /*
                                   html += '<button id="edit_btn" class="btn btn-outline-secondary btn-sm"  onclick="operation.editWindow('+index+')">编辑</button>';
                */
                html += '<button class="btn btn-outline-secondary btn-sm"  onclick="operation.addWindow(' + row.planDetailId + ')">执行详情</button>';
                return html;
            },
            setActImgUrl: function (value, row, index) {
                return '<img src="/TBook/queryPic?id=' + row.id + '" style="width:100px;heigth:100px"></img>';
            },
            setBorrow: function (value, row, index) {
                var htm = "";
                if (row.borrow == 0) {
                    htm = "未借阅";
                }
                if (row.borrow == 1) {
                    htm = "<span style='color:red;'>已借阅</span>";
                }
                return htm;
            },
        }

        var columns = [[

            {
                field: 'id',
                title: 'id',
                width: 10,
                align: 'center',
                visible: false
            },


            {title: '检修人', field: 'name', align: 'center', valign: 'middle', visible: true},
            {title: '部门', field: 'departmentName', align: 'center', valign: 'middle', visible: true},
            {title: '岗位', field: 'jobName', align: 'center', valign: 'middle', visible: true},
            {title: '计划名称', field: 'planName', align: 'center', valign: 'middle', visible: true},
            {title: '开始时间', field: 'planStar', align: 'center', valign: 'middle', visible: true},
            {title: '结束时间', field: 'planEnd', align: 'center', valign: 'middle', visible: true},
            {title: '机车', field: 'trainNo', align: 'center', valign: 'middle', visible: true},
            {title: '计划详情类型', field: 'planDetailType', align: 'center', valign: 'middle', visible: true},
            {title: '计划详情', field: 'planDetailInfo', align: 'center', valign: 'middle', visible: true},


            {title: '计划详情', field: 'planDetailId', align: 'center', valign: 'middle', visible: false},
            {title: '执行情况', field: 'excuteInfo', align: 'center', valign: 'middle', visible: true},
            {title: '执行人', field: 'userId', align: 'center', valign: 'middle', visible: false},
            {title: '执行状态', field: 'excuteStatus', align: 'center', valign: 'middle', visible: true},
            {title: '创建时间', field: 'createTime', align: 'center', valign: 'middle', visible: true},
            {title: '操作', field: 'opt', align: 'center', valign: 'middle', visible: true, formatter: fmt.setOpt},


        ]];


        $('#dg').bootstrapTable({
            url: "/ZcxPlanExcute/query",
            sidePagination: "server",
            queryParams: fmt.queryParams,
            method: "post",
            contentType: "application/x-www-form-urlencoded",
            pagination: true,
            pageNumber: 1,
            pageSize: 10,
            pageList: [10, 25, 50, 100],
            //search:true,
            clickToSelect: true,
            singleSelect: true,
            toolbar: '#toolbar',
            columns: columns,
        })

    });


    $(function () {
        $("#setFormId").bootstrapValidator({
            /* live:'disabled',
            excluded:[':disabled'],
            feedbackIcons: {
        　　　　　　　　valid: 'glyphicon glyphicon-ok',
        　　　　　　　　invalid: 'glyphicon glyphicon-remove',
        　　　　　　　　validating: 'glyphicon glyphicon-refresh'
    　　　　　   },*/
            fields: {


                planDetailId: {
                    validators: {
                        notEmpty: {
                            message: "计划详情不能为空!",
                        },
                    }

                },


                excuteInfo: {
                    validators: {
                        notEmpty: {
                            message: "执行情况不能为空!",
                        },
                    }

                },


                userId: {
                    validators: {
                        notEmpty: {
                            message: "执行人不能为空!",
                        },
                    }

                },


                excuteStatus: {
                    validators: {
                        notEmpty: {
                            message: "执行状态不能为空!",
                        },
                    }

                },


                createTime: {
                    validators: {
                        notEmpty: {
                            message: "创建时间不能为空!",
                        },
                    }

                },


            }

        });


    })


</script>

</body>

</html>
